package lines.gameengine.util;

import lines.gameengine.IBall;
import lines.gameengine.strategy.DefaultBallStrategyFactory;
import lines.gameengine.stub.StubField;
import org.junit.Before;
import org.junit.Test;

import java.util.Collection;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;

/**
 * @author vpotapenko
 */
public class DefaultBallGeneratorTest {

    private static final int BALLS_PER_STEP = 3;
    private static final int TYPES_NUMBER = 7;

    private DefaultBallGenerator generator;
    private StubField field;

    @Before
    public void setUp() throws Exception {
        field = new StubField(9, 9);
        field.context.parameters.setBallsPerStep(BALLS_PER_STEP);
        field.context.parameters.setTypesNumber(TYPES_NUMBER);


        generator = new DefaultBallGenerator(new DefaultBallStrategyFactory());
    }

    @Test public void shouldGenerateNextStepBall() {
        Collection<IBall> balls = generator.generateNextStepBalls(field);
        assertThat(balls.size(), equalTo(BALLS_PER_STEP));

        for (IBall ball : balls) {
            assertThat(ball.getValue() >= 0, equalTo(true));
            assertThat(ball.getValue() < TYPES_NUMBER, equalTo(true));
        }
    }
}
